using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Text;
using System.Web.Security;

namespace WCSFContrib.ECommerceCatalog.BusinessEntities
{
    public class Cart
    {
        private int cartId;

        public int CartId
        {
            get { return cartId; }
            set { cartId = value; }
        }
	
        private string user;

        public string User
        {
            get { return user; }
            set { user = value; }
        }

        private Collection<CartItem> cartItems = new Collection<CartItem>();

        public Collection<CartItem> CartItems
        {
            get { return cartItems; }
        }

        public double Total
        {
            get
            {
                double total = 0.0;

                foreach (CartItem cartItem in this.CartItems)
                {
                    total += cartItem.Quantity * cartItem.Item.Price;
                }

                return total;
            }
        }

        public Cart()
        {
        }

        public Cart(int cartId, string user, Collection<CartItem> cartItems)
        {
            this.cartId = cartId;
            this.user = user;
            this.cartItems = cartItems;
        }
    }
}
